﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Couple.Controls.OrdinaryBookingControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:wpftoolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    xmlns:converter="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:customControls="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Controls;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <converter:DateTimeToDateTimeString x:Key="dateConverter" />
        <converter:TimeSpanToHourMinuteString x:Key="timespanToHourMinuteConverter" />
        <converter:DateTimeToDayString x:Key="dateTimeToDayConverter" />

        <DataTemplate x:Key="TextBlockDataTemplate">
            <TextBlock Text="{Binding TimeBlock.StartDateTime, Converter={StaticResource dateConverter}}" 
                       TextDecorations="Underline" Background="Transparent" Width="120"/>
        </DataTemplate>

        <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="Padding" Value="10,0,0,0" />
        </Style>

        <Style TargetType="{x:Type ListView}">
            <Setter Property="Width" Value="120" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Height" Value="Auto" />
            <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
            <Setter Property="SelectionMode" Value="Single" />
        </Style>
        <Style x:Key="ListContainerStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="ContextMenu" Value="{DynamicResource ContextMenuKey}"></Setter>
            <Setter Property="Width" Value="100" />
            <Setter Property="FontFamily" Value="Arial"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="Foreground" Value="#FF77B6EB"/>
            <Setter Property="IsSelected" Value="False" /> 
        </Style>

    </UserControl.Resources>

    <Grid x:Name="GridOrdinaryBooking" IsEnabled="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Label Content="År-Månad" Grid.Row="0" Grid.Column="0" />
            <TextBox x:Name="TextBoxMonth" IsReadOnly="True" Grid.Row="1" Grid.Column="0" 
                     Width="60" Margin="4,0,5,10" VerticalAlignment="Top" HorizontalAlignment="Left" />
            
            <Grid Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="2" Margin="0,0,0,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Label Content="Dag" Grid.Row="0" Grid.Column="1" />
                <Label Content="Klockslag" Grid.Row="0" Grid.Column="2" Margin="4,0,0,0"/>

                <ComboBox Grid.Column="1" Grid.Row="1" x:Name="ComboBoxDay" Width="40"
                          DataContext="{Binding Path=SelectedDate, RelativeSource={RelativeSource TemplatedParent}}"
                          SelectionChanged="ComboBoxDay_SelectionChanged">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Date, Converter={StaticResource dateTimeToDayConverter}}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <ComboBox Grid.Column="2" Grid.Row="1" x:Name="ComboBoxTime" Margin="5,0,0,0" Width="60" 
                          DataContext="{Binding Path=SelectedDate, RelativeSource={RelativeSource TemplatedParent}}"
                          SelectionChanged="ComboBoxTime_SelectionChanged">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=TimeOfDay, Converter={StaticResource timespanToHourMinuteConverter}}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>

            <Label Content="Önskad tid 1:" Grid.Column="0" Grid.Row="2" />
            <Label Content="Önskad tid 2:" Grid.Column="0" Grid.Row="3" />

            <customControls:DateTimePicker x:Name="PreferredDate1Picker" Grid.Column="1" Grid.Row="2" Margin="0,0,0,2" HorizontalAlignment="Left" 
                                           SelectedDate="{Binding PreferredDate1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
            <customControls:DateTimePicker x:Name="PreferredDate2Picker" Grid.Column="1" Grid.Row="3" Margin="0,0,0,2" 
                                           VerticalAlignment="Top" HorizontalAlignment="Left" 
                                           SelectedDate="{Binding PreferredDate2, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

            <CheckBox x:Name="CheckBoxBookOrdinaryDateTime" Grid.Column="3" Grid.Row="1" Content="Ja, boka denna tid" Margin="8,0,0,0" Padding="5,0,0,10" 
                      VerticalAlignment="Center" Checked="CheckBoxBookOrdinaryDateTime_Checked" Unchecked="CheckBoxBookOrdinaryDateTime_Unchecked" IsChecked="False" />
            <CheckBox x:Name="CheckBoxBookPreferredDate1" Grid.Column="3" Grid.Row="2" Content="Ja, boka denna tid" Margin="8,0,0,0" Padding="5,0,0,0" 
                      VerticalAlignment="Center" Checked="CheckBoxBookPreferredDate1_Checked" Unchecked="CheckBoxBookPreferredDate1_Unchecked" IsChecked="False" />
            <CheckBox x:Name="CheckBoxBookPreferredDate2" Grid.Column="3" Grid.Row="3" Content="Ja, boka denna tid" Margin="8,0,0,0" Padding="5,0,0,0" 
                      VerticalAlignment="Center" Checked="CheckBoxBookPreferredDate2_Checked" Unchecked="CheckBoxBookPreferredDate2_Unchecked" IsChecked="False" IsEnabled="False" />
        </Grid>

        <TabControl x:Name="TabControlTimes" Grid.Column="1" Grid.RowSpan="2" Margin="15,0,0,0">

            <TabItem x:Name="TabItemNearestTimes" Header="Närmast" VerticalContentAlignment="Top">

                <ListView x:Name="listViewNearestTime" Margin="5,10,5,5"
                          SelectionChanged="listViewNearestTime_SelectionChanged"
                          ItemContainerStyle="{StaticResource ListContainerStyle}"
                          ItemTemplate="{StaticResource TextBlockDataTemplate}"
                          ScrollViewer.VerticalScrollBarVisibility="Auto" SelectedItem="">
                </ListView>

            </TabItem>

            <TabItem x:Name="TabItemAllTimes" Header="Alla" VerticalContentAlignment="Top">

                <wpftoolkit:Calendar x:Name="calendarControl" Language="sv-SE" FirstDayOfWeek="Monday" Grid.Column="2" Grid.Row="0" 
                                     SelectionMode="SingleDate"></wpftoolkit:Calendar>
                
            </TabItem>

        </TabControl>

        <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Margin="0,10,0,0"
                    Orientation="Horizontal" HorizontalAlignment="Right">
            <Button x:Name="CancelButton" Content="Avboka" IsEnabled="False" Margin="5,0,0,0" Click="CancelButton_Click"/>
            <Button x:Name="SaveButton" Content="Boka" Command="{Binding SaveCommand}" IsEnabled="True" Margin="5,0,0,0" Click="SaveButton_Click" />
        </StackPanel>

    </Grid>

</UserControl>
